<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use Carbon\Carbon;

use App\Service\Model\DayTotal as DayTotalModel;
use App\Service\Model\Agency;

/**
 * DayTotal
 * 
 */
class DayTotalCreate extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'day:total';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = ' ';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $agency = Agency::all();
        foreach($agency as $v){
            DayTotalModel::create([
                'date'          => Carbon::now()->toDateString(),
                'agency_id'     => $v->getKey(),
                'agency_name'   => $v->name,
                'invite_code'   => $v->invite_code,
                'agency_level'  => $v->level,
                'ratio'         => $v->ratio,
            ]);
        }
    }
    
}
